package com.legal.aid.system.service.impl;

import com.legal.aid.common.core.domain.entity.CommonUser;
import com.legal.aid.system.mapper.SysCommonUserMapper;
import com.legal.aid.system.service.ISysCommonUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SysCommonUserServiceImpl implements ISysCommonUserService {

    @Autowired
    private SysCommonUserMapper sysCommonUserMapper;

    /**
     * 获取app登录用户信息
     * @param username
     * @return
     */
    @Override
    public CommonUser selectUserByUserName(String username) {

        return sysCommonUserMapper.getCommonUserByUsername(username);

    }

    /**
     * 判断改用户是否存在  不存在为false
     * @param commonUser
     * @return
     */
    @Override
    public boolean checkUserNameUnique(CommonUser commonUser) {
        return sysCommonUserMapper.getCommonUserByUsername(commonUser.getUserName()) == null;
    }

    @Override
    public boolean registerCommonUser(CommonUser commonUser) {
        return sysCommonUserMapper.insertCommonUser(commonUser) > 0;
    }

    @Override
    public boolean updateCommonUser(CommonUser commonUser) {
        return sysCommonUserMapper.updateCommonUser(commonUser) > 0;
    }

    @Override
    public CommonUser selectCommonUserById(Long id) {
        return sysCommonUserMapper.selectCommonUserById(id);
    }
}
